package listen

import (
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/columnd"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/factory"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/infod"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/core/interactiond"
	"gogs.xiaoyuanjijiehao.com/antlinker/antcms/ddd"
)

type listener struct {
	iar  infod.InfoAggregateRoot
	iiar interactiond.InteractionAggregateRoot
	irar interactiond.ReplayAggregateRoot
	igar interactiond.GroupAggregateRoot
	car  columnd.ColumnAggregateRoot
}

func (l listener) InfoCountAddOne(ctx ddd.Context, evt ddd.Event, uid string, targetTyp interactiond.IGTargetType, targetid string) error {
	g, err := factory.DefaultFactory.GetOrCreIGroup(ctx, targetTyp, targetid)
	if err != nil {
		return err
	}
	_, err = l.iiar.AddInteraction(ctx, interactiond.InteractionDesc{
		IGID:  g.IGID,
		Code:  "count",
		UID:   uid,
		Value: 1,
	})
	return err
}
